<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../rest.js"></script>
    lin
</head>

<body>
    <button class="btn">新增</button>
    <button class="btn">新增</button>
    <button class="btn">交换</button>
    <div class="wrap">
        <ul class="list">
            <li>01</li>
            <li>02</li>
            <li class="mid">03</li>
            <li>04</li>
            <li>05</li>
            <li>06</li>
        </ul>
    </div>
    <script>
        var list = document.querySelector('.list')
        var mid = document.querySelector('.mid')
        var btn1 = document.getElementsByClassName('btn')[0]
        var btn2 = document.getElementsByClassName('btn')[1]
        var btn3 = document.getElementsByClassName('btn')[2]
        var li = document.createElement('li')

        btn1.onclick = function () {
            var li = document.createElement('li')
            li.innerHTML = '我可是一个新增的li哦'
            li.style.background = randColor()
            list.append(li)
        }
        btn2.onclick = function () {
            var li = document.createElement('li')
            li.innerHTML = '我可是一个新增的li哦'
            li.style.background = randColor()
            list.insertBefore(li, mid)
        }
        btn3.onclick = function () {
            var li = document.createElement('li')
            li.innerHTML = '我可是一个新增的li哦'
            li.style.background = randColor()
            list.insertBefore(list.firstElementChild, list.lastElementChild)
        }


    </script>
</body>

</html>